﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Windows8Accelerator.Core.Xaml.Controls
{
    public class ItemSize
    {
        public ItemSize(string text)
        {
            if (text.Contains(","))
            {
                var parts = text.Split(',');
                _Width = new ItemLength(parts[0]);
                _Height = new ItemLength(parts[1]);
            }
            else
            {
                _Width = _Height = new ItemLength(text);            
            }
        }

        public ItemSize(ItemLength width, ItemLength height)
        {
            _Width = width;
            _Height = height;
        }

        public static ItemLength Auto
        {
            get
            {
                return new ItemLength("Auto,Auto");
            }
        }

        public static explicit operator ItemSize(string text)
        {
            return new ItemSize(text);
        }

        private ItemLength _Width;
        public ItemLength Width
        {
            get { return _Width; }
            set { _Width = value; }
        }

        private ItemLength _Height;
        public ItemLength Height
        {
            get { return _Height; }
            set { _Height = value; }
        }

        public override string ToString()
        {
            return string.Format("{0},{1}",Width,Height);
        }
    }
}
